package Exams.MeituanPack.q2021.q06_code;

import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        var reader = new BufferedReader(new InputStreamReader(System.in));
        var writer = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(reader.readLine());
        char[] s = reader.readLine().toCharArray();

        int l = 0, r = 0;

        boolean flag = false;
        for (int i = 0; i < n; i++) {
            char c = s[i];
            if (c == 'M') flag = true;
            if (flag && c == 'T') {
                l = i + 1;
                break;
            }
        }

        flag = false;
        for (int i = n - 1; i >= 0; i--) {
            char c = s[i];
            if (c == 'T') flag = true;
            if (flag && c == 'M') {
                r = i - 1;
                break;
            }
        }

        writer.write(String.valueOf(s).substring(l, r + 1));

        writer.flush();
        reader.close();
        writer.close();

    }
}
